/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lomanda
 */
@Entity
@Table(name = "contaBancaria")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ContaBancaria.findAll", query = "SELECT c FROM ContaBancaria c"),
    @NamedQuery(name = "ContaBancaria.findByIdContaB", query = "SELECT c FROM ContaBancaria c WHERE c.idContaB = :idContaB"),
    @NamedQuery(name = "ContaBancaria.findByNumero", query = "SELECT c FROM ContaBancaria c WHERE c.numero = :numero"),
    @NamedQuery(name = "ContaBancaria.findByDataAbertura", query = "SELECT c FROM ContaBancaria c WHERE c.dataAbertura = :dataAbertura"),
    @NamedQuery(name = "ContaBancaria.findByAgenciaAbertura", query = "SELECT c FROM ContaBancaria c WHERE c.agenciaAbertura = :agenciaAbertura"),
    @NamedQuery(name = "ContaBancaria.findByDetalhe", query = "SELECT c FROM ContaBancaria c WHERE c.detalhe = :detalhe")})
public class ContaBancaria implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataAbertura")
    @Temporal(TemporalType.DATE)
    private Date dataAbertura;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idContaB")
    private Integer idContaB;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "numero")
    private String numero;
    @Size(max = 45)
    @Column(name = "agenciaAbertura")
    private String agenciaAbertura;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 500)
    @Column(name = "detalhe")
    private String detalhe;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkContaB")
    private List<ContaBancariaTitular> contaBancariaTitularList;
    @JoinColumn(name = "fkBanco", referencedColumnName = "idBanco")
    @ManyToOne(optional = false)
    private Banco fkBanco;

    public ContaBancaria() {
    }

    public ContaBancaria(Integer idContaB) {
        this.idContaB = idContaB;
    }

    public ContaBancaria(Integer idContaB, String numero, Date dataAbertura, String detalhe) {
        this.idContaB = idContaB;
        this.numero = numero;
        this.dataAbertura = dataAbertura;
        this.detalhe = detalhe;
    }

    public Integer getIdContaB() {
        return idContaB;
    }

    public void setIdContaB(Integer idContaB) {
        this.idContaB = idContaB;
    }

    public String getNumero() {
        return numero;
    }

    public void setNumero(String numero) {
        this.numero = numero;
    }

    public String getAgenciaAbertura() {
        return agenciaAbertura;
    }

    public void setAgenciaAbertura(String agenciaAbertura) {
        this.agenciaAbertura = agenciaAbertura;
    }

    public String getDetalhe() {
        return detalhe;
    }

    public void setDetalhe(String detalhe) {
        this.detalhe = detalhe;
    }

    @XmlTransient
    public List<ContaBancariaTitular> getContaBancariaTitularList() {
        return contaBancariaTitularList;
    }

    public void setContaBancariaTitularList(List<ContaBancariaTitular> contaBancariaTitularList) {
        this.contaBancariaTitularList = contaBancariaTitularList;
    }

    public Banco getFkBanco() {
        return fkBanco;
    }

    public void setFkBanco(Banco fkBanco) {
        this.fkBanco = fkBanco;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idContaB != null ? idContaB.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ContaBancaria)) {
            return false;
        }
        ContaBancaria other = (ContaBancaria) object;
        if ((this.idContaB == null && other.idContaB != null) || (this.idContaB != null && !this.idContaB.equals(other.idContaB))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.ContaBancaria[ idContaB=" + idContaB + " ]";
    }

    public Date getDataAbertura() {
        return dataAbertura;
    }

    public void setDataAbertura(Date dataAbertura) {
        this.dataAbertura = dataAbertura;
    }
    
}
